<?php

/**
 * 计算活跃时间
 */
function calculateTime($time)
{
	$result_str = '';
	$last_time = strtotime($time);
	if (time() - $last_time < 60) {//一分钟内
		$result_str = time() - $last_time . '<span style="color:#e02433">秒</span>前';
	} elseif (time() - $last_time >= 60 && time() - $last_time < 3600) {//一小时内
		$result_str = intval((time() - $last_time) / 60) . '<span style="color:#e02433">分钟</span>前';
	} else if (time() - $last_time >= 3600 && time() - $last_time < 86400) {//一天内
		$result_str = intval((time() - $last_time) / 3600) . '<span style="color:#e02433">小时</span>前';
	} else {
		$result_str = intval((time() - $last_time) / 86400) . '<span style="color:#e02433">天</span>前';
	}
	return $result_str;
}